package com.ktgj.pay.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.pay.domain.InvoiceOperatelog;
import com.ktgj.pay.service.IInvoiceOperatelogService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 发票操作日志Controller
 * 
 * @author ruoyi
 * @date 2022-01-24
 */
@RestController
@RequestMapping("/operatelog")
public class InvoiceOperatelogController extends BaseController
{
    @Autowired
    private IInvoiceOperatelogService invoiceOperatelogService;

    /**
     * 查询发票操作日志列表
     */
    @PreAuthorize(hasPermi = "invoice:operatelog:list")
    @GetMapping("/list")
    public TableDataInfo list(InvoiceOperatelog invoiceOperatelog)
    {
        startPage();
        List<InvoiceOperatelog> list = invoiceOperatelogService.selectInvoiceOperatelogList(invoiceOperatelog);
        return getDataTable(list);
    }

    /**
     * 导出发票操作日志列表
     */
    @PreAuthorize(hasPermi = "invoice:operatelog:export")
    @Log(title = "发票操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvoiceOperatelog invoiceOperatelog) throws IOException
    {
        List<InvoiceOperatelog> list = invoiceOperatelogService.selectInvoiceOperatelogList(invoiceOperatelog);
        ExcelUtil<InvoiceOperatelog> util = new ExcelUtil<InvoiceOperatelog>(InvoiceOperatelog.class);
        util.exportExcel(response, list, "发票操作日志数据");
    }

    /**
     * 获取发票操作日志详细信息
     */
    @PreAuthorize(hasPermi = "invoice:operatelog:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(invoiceOperatelogService.selectInvoiceOperatelogById(id));
    }

    /**
     * 新增发票操作日志
     */
    @PreAuthorize(hasPermi = "invoice:operatelog:add")
    @Log(title = "发票操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvoiceOperatelog invoiceOperatelog)
    {
        return toAjax(invoiceOperatelogService.insertInvoiceOperatelog(invoiceOperatelog));
    }

    /**
     * 修改发票操作日志
     */
    @PreAuthorize(hasPermi = "invoice:operatelog:edit")
    @Log(title = "发票操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvoiceOperatelog invoiceOperatelog)
    {
        return toAjax(invoiceOperatelogService.updateInvoiceOperatelog(invoiceOperatelog));
    }

    /**
     * 删除发票操作日志
     */
    @PreAuthorize(hasPermi = "invoice:operatelog:remove")
    @Log(title = "发票操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(invoiceOperatelogService.deleteInvoiceOperatelogByIds(ids));
    }
}
